
////////////////////////////////////////////////////////////////////////////////////////////
// 文件名: Sys_RoleDAL.gen.cs
//
// 模块名称: Sys_RoleInfo
//
// 作者: zxf
//
// 历史记录（记录修改记录，修改文件后请添加修改记录，注明修改时间、修改人，修改内容）:
// 2013/1/17    zxf    创建文件
////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using HIDB;
using Model;
using Common;

namespace DAL
{
	/// <summary>
	/// Sys_RoleInfo表数据访问层
	/// </summary>
	public partial class Sys_RoleDAL
	{
		/// <summary>
		/// 根据RoleID字段获取Sys_RoleInfo实体对象
		/// </summary>
		/// <param name="roleID">RoleID</param>
		/// <returns>Sys_RoleInfo实体对象</returns>
		public static Sys_RoleInfo GetInfoById(string roleID)
		{
			////创建Database对象
			//Database db = DatabaseFactory.CreateDatabase();
			////创建DbCommand对象
			//DbCommand dbCommand = db.GetStoredProcCommand("UP_Sys_RoleInfo_Select");

			////添加输入输出参数
			//db.AddInParameter(dbCommand, "@RoleID", DbType.String, roleID);

			////执行命令返回DataReader对象
			//using (IDataReader dr = db.ExecuteReader(dbCommand))
			//{
			//    return dr.Read() ? CreateSys_RoleInfo(dr) : null;
			//}
			return null;
		}

		/// <summary>
		/// 获取Sys_RoleInfo实体对象列表
		/// </summary>
		public static List<Sys_RoleInfo> GetInfoList()
		{
			HIDB.dbo con = HIDB.common.make();
			List<Sys_RoleInfo> list = new List<Sys_RoleInfo>();

			try
			{
				DataTable dt = new DataTable();
				dt=con.StoredDataTable("UP_Sys_RoleInfo_GetList");
				foreach (DataRow row in dt.Rows)
				{
					Sys_RoleInfo model = new Sys_RoleInfo();
					model.RoleID = row["RoleID"].ToString();
					model.RoleName = row["RoleName"].ToString();
					model.RoleType = row["RoleType"].ToString();
					model.Description = row["Description"].ToString();
					model.CreatedTime =DateTime.Parse(row["CreatedTime"].ToString());

					list.Add(model);
				}
			}
			catch (Exception ex)
			{
				Logger.LogError("UP_Sys_RoleInfo_GetList", "UP_Sys_RoleInfo_GetList", 0, 1, ex, "", "");
			}

			return list;
		}
		/// <summary>
		/// 往Sys_RoleInfo表内添加新记录
		/// </summary>
		/// <param name="Sys_RoleInfo">Sys_RoleInfo实体对象</param>
		/// <returns>添加记录索引值</returns>
		public static int Insert(Sys_RoleInfo sysRoleInfo)
		{
			//创建Database对象
			int num = -1;
			
			HIDB.dbo con = HIDB.common.make();

			//添加输入输出参数
			SqlParameter[] sqlparams = { 
                                        new SqlParameter("@RoleID",sysRoleInfo.RoleID)
                                        ,new SqlParameter("@RoleName",sysRoleInfo.RoleName)
                                        ,new SqlParameter("@RoleType",sysRoleInfo.RoleType)
                                        ,new SqlParameter("@Description",sysRoleInfo.Description)
										,new SqlParameter("@CreatedTime",sysRoleInfo.CreatedTime)
                                       };
			try
			{
                con.StoredUpdate("[dbo].[UP_SysRoleInfo_Insert]", sqlparams);
				num = 1;
			}
			catch (Exception ex)
			{
				Logger.LogError("UP_Sys_RoleInfo_Insert", "UP_Sys_RoleInfo_Insert", 0, 1, ex, "", "");
			}

			return num;

		}

		/* /// <summary>
		 /// 更新Sys_RoleInfo表记录
		 /// </summary>
		 /// <param name="Sys_RoleInfo">Sys_RoleInfo实体对象</param>
		 public static int Update(Sys_RoleInfo sysRoleInfo)
		 {
			 //创建Database对象
			 Database db = DatabaseFactory.CreateDatabase();
			 //创建DbCommand对象
			 DbCommand dbCommand = db.GetStoredProcCommand("UP_Sys_RoleInfo_Update");
            
			 //添加输入输出参数
			 db.AddInParameter(dbCommand, "@RoleID", DbType.String, sysRoleInfo.RoleID);
			 db.AddInParameter(dbCommand, "@RoleName", DbType.String, sysRoleInfo.RoleName);
			 db.AddInParameter(dbCommand, "@RoleType", DbType.AnsiStringFixedLength, sysRoleInfo.RoleType);
			 db.AddInParameter(dbCommand, "@Description", DbType.String, sysRoleInfo.Description);
			 db.AddInParameter(dbCommand, "@CreatedTime", DbType.DateTime, sysRoleInfo.CreatedTime);
            
			 return db.ExecuteNonQuery(dbCommand);
		 }
        
		 /// <summary>
		 /// 根据RoleID字段删除Sys_RoleInfo表信息
		 /// </summary>
		 /// <param name="roleID">RoleID</param>
		 public static int Delete(string roleID)
		 {
			 //创建Database对象
			 Database db = DatabaseFactory.CreateDatabase();
			 //创建DbCommand对象
			 DbCommand dbCommand = db.GetStoredProcCommand("UP_Sys_RoleInfo_Delete");
            
			 //添加输入输出参数
			 db.AddInParameter(dbCommand, "@RoleID", DbType.String, roleID);

			 return db.ExecuteNonQuery(dbCommand);
		 }
        
		 /// <summary>
		 /// 生成Sys_RoleInfo实体对象
		 /// </summary>
		 private static Sys_RoleInfo CreateSys_RoleInfo(IDataReader rdr)
		 {
			 Sys_RoleInfo mySys_RoleInfo = new Sys_RoleInfo
			 {
				 RoleID = DBConvert.GetString(rdr, "RoleID"),
				 RoleName = DBConvert.GetString(rdr, "RoleName"),
				 RoleType = DBConvert.GetAnsiStringFixedLength(rdr, "RoleType"),
				 Description = DBConvert.GetString(rdr, "Description"),
				 CreatedTime = DBConvert.GetDateTime(rdr, "CreatedTime")
			 };

			 return mySys_RoleInfo;
		 }*/
	}
}